#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x, y; cin >> x >> y;
	ll t = x * y;
	ll ans = 0;
	for (ll i = 1; i * i <= t; i++) {
		if (t % i == 0 && gcd(i, t / i) == x) ans += 2;
	}
	if (x == y) ans--;
	cout << ans << endl;
	return 0;
}